﻿using System;
using System.Data;
using System.Configuration;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;
using System.Net.Mail;

namespace MeetingMinutesManager
{
    public class EmailOperator
    {
        public static void Send(String subject, String messageBody, MailAddressCollection addressCollection,
               MailAddress sender, bool isBodyHTML, AttachmentCollection attachments)
        {
            MailMessage mail = new MailMessage();
            if (sender == null)
            {
                mail.From = new MailAddress("rain.wei@bleum.com");
            }
            else
            {
                mail.From = sender;
            }

            foreach (MailAddress address in addressCollection)
            {
                mail.To.Add(address);
            }

            mail.Subject = subject;
            mail.Body = messageBody;

            mail.IsBodyHtml = isBodyHTML;
            mail.Priority = MailPriority.High;

            if (attachments != null)
            {
                foreach (Attachment attachment in attachments)
                {
                    mail.Attachments.Add(attachment);
                }
            }

            SmtpClient client = new SmtpClient("mail.bleum.com");
            client.DeliveryMethod = SmtpDeliveryMethod.Network;
            client.Send(mail);
        }
    }
}
